﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Telerik.Web.Mvc;
using PeopleSource.Utl;
using PeopleSource.Entities;

namespace PeopleSource.Controllers
{
    public class InterviewStateController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [GridAction]
        public ActionResult _SelectIndex(int? resumetype, int? jobtitle, string applyer)
        {
            return View(new GridModel((CH.GetAllDatas<InterviewState>())));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _SaveAjaxEditing(int? id)
        {
            var item = CH.GetDataByID<InterviewState>(id);

            if (TryUpdateModel(item))
            {

                CH.Edit<InterviewState>(item);
            }
            return View(new GridModel((CH.GetAllDatas<InterviewState>())));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _InsertAjaxEditing(int? id)
        {
            var item = new InterviewState();

            if (TryUpdateModel(item))
            {

                CH.Create<InterviewState>(item);
            }
            return View(new GridModel((CH.GetAllDatas<InterviewState>())));
        }

        [AcceptVerbs(HttpVerbs.Post)]
        [GridAction]
        public ActionResult _DeleteAjaxEditing(int? id)
        {
            CH.Delete<InterviewState>(id);
            return View(new GridModel((CH.GetAllDatas<InterviewState>())));
        }

    }
}
